package messageMeUtility.user;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

import messageMeUtility.interfaces.IMessage;
import messageMeUtility.interfaces.IUser;

public class StandardUser implements IUser {

	private Stack<IMessage> messages = null;
	
	private String username = "";
	private String email = "";
	private String password = "";

	public StandardUser(String username, String email, String password) {
		this.setUsername(username);
		this.setEmail(email);
		this.setPassword(password);
		this.messages = new Stack<IMessage>();
	}

	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {

		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public synchronized List<IMessage> getMessages() {

		List<IMessage> result = new ArrayList<IMessage>();

		while (!this.messages.empty()) {
			result.add(this.messages.pop());
		}

		return result;
	}

	public synchronized void addMessage(IMessage message) {
		this.messages.add(message);
	}

}
